from marshmallow import Schema, fields, validate


class AddCategorySchema(Schema):
    categoryName = fields.Str(
        required=True,
        validate=validate.Length(min=1, error="分类名称不能为空"),
    )
    categoryAlias = fields.Str(
        required=True,
        validate=validate.Length(min=1, error="分类别名不能为空"),
    )


class UpdateCategorySchema(Schema):
    id = fields.Int(
        required=True,
        validate=validate.Range(min=1, error="id违法")
    )
    categoryName = fields.Str(
        required=True,
        validate=validate.Length(min=1, error="分类名称不能为空"),
    )
    categoryAlias = fields.Str(
        required=True,
        validate=validate.Length(min=1, error="分类别名不能为空"),
    )
